<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/HomeTemplate.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                >
    <ui:define name="body">

        <div class="main-container" >

            <h:form>
                <p:panelGrid columns="2">
                    <p:column>
                        <p:panelMenu style="width:200px; text-align: left">
                            <p:submenu label="Dealers" >
                                <p:menuitem value="Dealer Managment" icon="ui-icon-bullet" />

                            </p:submenu>
                            <p:submenu label="Order">
                                <p:menuitem value="Brand Managment "  icon="ui-icon-bullet" url="AdminParametricBrand.xhtml"/>
                                <p:menuitem value="Product Type Managment "  icon="ui-icon-bullet" url="AdminParametricProduct.xhtml" />
                                <p:menuitem value="Category Managment"   icon="ui-icon-bullet" url="AdminParametricCategory.xhtml"/>
                                <p:menuitem value="Catalog Managment"  icon="ui-icon-bullet" url="AdminParametricCatalog.xhtml"/>
                                <p:menuitem value="Inventory Managment"  icon="ui-icon-bullet" url="AdminParametricInventory.xhtml"/>
                            </p:submenu>
                            <p:submenu label="Account">
                                <p:menuitem value="Delete"   icon="ui-icon-bullet"/>
                            </p:submenu>
                            <p:submenu label="Warranty" >
                                <p:submenu label="Links" icon="ui-icon-bullet">
                                    <p:submenu label="PrimeFaces" icon="ui-icon-bullet">
                                        <p:menuitem value="Home" url="http://www.primefaces.org" icon="ui-icon-bullet" />
                                    </p:submenu>
                                </p:submenu>
                                <p:menuitem value="Mobile" icon="ui-icon-bullet" />
                            </p:submenu>
                            <p:submenu label="Marketing">
                                <p:menuitem value="Save" icon="ui-icon-bullet" />

                            </p:submenu>


                        </p:panelMenu>
                    </p:column>  
                    <p:column>

                        <p:row>
                            <p:growl id="growl" showDetail="true"/>  
                            <p:growl id="msgs" showDetail="true" />
                            <p:dataTable id="lineTable2" var="line" value="#{lineBean.lines}" widgetVar="lineTableW" paginator="true" 
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks}
                                         {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" paginatorPosition="bottom"
                                         rows="10" rowsPerPageTemplate="10,20,40" 
                                         >  
                                <f:facet name="header">
                                    Products
                                </f:facet>
                                <p:ajax event="rowSelect" listener="#{lineBean.onRowSelect}" update=":#{p:component('msgs')}"  />
                                <p:ajax event="rowUnselect" listener="#{lineBean.onRowUnselect}" update=":#{p:component('msgs')}" />
                                <p:column filterBy="#{line.inBrand.description}" >  
                                    <f:facet name="header">  
                                        Brand
                                    </f:facet>  

                                    <h:outputText value="#{line.inBrand.description}" />  

                                </p:column> 

                                <p:column >  
                                    <f:facet name="header">  
                                        Description
                                    </f:facet>  

                                    <h:outputText value="#{line.description}" />  

                                </p:column> 
                                <p:column >  
                                    <f:facet name="header">  
                                        Character
                                    </f:facet>  

                                    <h:outputText value="#{line.characters}" />  

                                </p:column>  
                                <p:column headerText="Status" filterBy="#{line.status}" filterMatchMode="equals">  
                                    <h:outputText value="#{line.status ? 'Active': 'Disable'}" />  

                                </p:column> 

                                <f:facet name="footer">  
                                    In total there are #{lineBean.lines.size()} Items.  
                                </f:facet>  

                            </p:dataTable> 

                            <p:row>
                                <p:commandButton  value="Add" onclick="panelwv.show();"  type="button" > </p:commandButton> 
                                <p:commandButton  value="Update" onclick="panelwv.show();" type="button"> </p:commandButton> 
                                <p:commandButton  value="Remove"  > </p:commandButton>   
                                <p:commandButton  value="Excel" action="#{reporteController.submit()}" immediate="true" ajax="false"> </p:commandButton>  
                            </p:row>


                            <p:panel id="editPanel" header="Add new Product" widgetVar="panelwv" visible="false" style="margin-top: 10px" >  
                                <p:row >

                                    <p:column>
                                        <h:outputText value="Brand: *" /> 
                                        <p:selectOneMenu id="brand" required="true" value="#{lineBean.line.inBrand}" converter="#{brandConverter}" style="width: 228px;">  
                                            <f:selectItem itemLabel="Select Brand" itemValue="" />  
                                            <f:selectItems value="#{brandBean.brands}" var="brand" itemLabel="#{brand.name}" itemValue="#{brand}"/>  
                                        </p:selectOneMenu> 

                                    </p:column>
                                    <p:column>
                                        <h:outputText value="Description: *" />   
                                        <p:inputText id="desc" value="#{lineBean.line.description}" required="true" label="desc"/> 
                                    </p:column>

                                    <p:column>
                                        <h:outputText value="SKU Characters: *" />   
                                        <p:inputText id="character" value="#{lineBean.line.characters}" required="true" label="character"/> 
                                    </p:column>

                                </p:row>
                                <p:row>
                                    <p:commandButton value="Save" actionListener="#{lineBean.saveLine()}" update="lineTable2" ajax="false"/>

                                    <p:commandButton value="Cancel" update="editPanel" process="@this" actionListener="#{lineBean.resetFail}"/>
                                </p:row>
                            </p:panel>  

                        </p:row> 
                    </p:column>
                </p:panelGrid>
            </h:form>
        </div>
    </ui:define>
</ui:composition>

